package com.carhome.ui.fagment;

import com.carhome.R;
import com.carhome.adapter.CarFragmentSearchAdapter;
import com.carhome.bean.CarSearchCondition;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class CarFragmentBySecondCar extends Fragment {
	// 界面上的控件
	private ListView mListView;
	private TextView mTextView;

	private CarFragmentSearchAdapter mAdapter;
	// 解析布局
	private View mView;

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.car_fragment_bysecondcar, container, false);
		initViews();
		return mView;
	}

	private void initViews() {
		mListView = (ListView) mView.findViewById(R.id.car_fragment_bysecondcar_listview);
		mTextView = (TextView) mView.findViewById(R.id.car_fragment_bysecondcar_textview);
		mTextView.setOnClickListener(myClickListener);
		mListView.setOnItemClickListener(mylistviewItemClickListener);

		mAdapter = new CarFragmentSearchAdapter(getActivity());
		mAdapter.addData(new CarSearchCondition("地区", "北京"));
		mAdapter.addData(new CarSearchCondition("品牌", "不限"));
		mAdapter.addData(new CarSearchCondition("价格", "不限"));
		mAdapter.addData(new CarSearchCondition("里程", "不限"));
		mAdapter.addData(new CarSearchCondition("车龄", "不限"));
		mAdapter.addData(new CarSearchCondition("级别", "不限"));
		mAdapter.addData(new CarSearchCondition("来源", "不限"));

		mListView.setAdapter(mAdapter);
	}

	private OnItemClickListener mylistviewItemClickListener = new OnItemClickListener() {

		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

		}
	};

	private OnClickListener myClickListener = new OnClickListener() {
		public void onClick(View v) {
			// TODO
		}
	};

}
